# -*- conding:utf-8 -*-

"""
@author: PoXiao
@file: main2.py
@time: 2019/3/25 0025 20:00

"""
from Fitness import *

import scipy.io
import time
from dijkstar import fordijkstar
from forText import readData

time_start=time.time()
data1 = scipy.io.loadmat('bianld.mat')
# data1 = scipy.io.loadmat('config.mat')
# car, cross, road = readData('1-map-training-1')
# data2 = scipy.io.loadmat('pop8.mat')
# road = data1['Road']
# car = data1['Car']
# cross = data1['Cross']

road = data1['road']
car = data1['car']
cross = data1['cross']
vlist_table = fordijkstar(car, cross, road)
# pop = data2['pop']
# chromosome: 车道ID，出发时间，表示路径的染色体
chromosome = np.zeros([car.shape[0],cross.shape[0]], int)
chromosome = np.concatenate((car[:,0:5:4], chromosome), axis=1)
# for i in range(car.shape[0]):
#     startPoint = int(car[i][1])
#     chromosome[i][startPoint+1]=1
fitness = Fitness(chromosome, -1, road, car, cross, [], vlist_table)
crossMap = fitness.creat_crossMap()
road = fitness.creat_roadMap()
fitness.traffic_fitness()

time_end=time.time()
print('time cost',time_end-time_start,'s')



